package ge.unihack.instantdj.utils;

import ge.unihack.instantdj.R;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;

public class PlayerDvijenia {
	
	private static MediaPlayer mp;
	
	public static void pauseAll(){
		
	}
	
	public static void playAll(){
		
	}
	
	public static void play(int currentLoop, String name){
		
	}
	
	public static void play(Context con,int currentLoop, final String name) throws InterruptedException{
		
		int def = 10;
		while(currentLoop != def){
			Thread.sleep(1000);
			currentLoop +=1;
		}
		
		int soundId = con.getResources().getIdentifier(name, "raw", "ge.unihack.instantdj");
		if(mp!=null)
			mp.release();
		mp = MediaPlayer.create(con, R.raw.drum_5);
        mp.setScreenOnWhilePlaying(true);
        mp.setLooping(true);
        mp.setOnCompletionListener(new OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mp) {
            	
            }
        });   
        mp.start();
	}
	
	public static void pause(Context con){
		if(mp != null)
			mp.pause();
	}
}
